//
// Copyright (C) 2011 Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.101
//#include "stdafx.h"
#include "YoYInflationCapFloor.h"
using namespace Cephei::QL::Instruments;
#include <gen/QL/Termstructures/YieldTermStructure.h>
#include <gen/QL/Termstructures/YoYInflationTermStructure.h>
#include <gen/QL/Cashflows/YoYInflationCoupon.h>
#include <gen/QL/CashFlow.h>
#include <gen/QL/PricingEngine.h>
#include <gen/QL/Instrument.h>
using namespace Cephei::QL::Termstructures;
using namespace Cephei::QL::Cashflows;
using namespace Cephei::QL;
#define HANDLE
#undef ABSTRACT
#define STRUCT
Cephei::QL::Instruments::CYoYInflationCapFloor::CYoYInflationCapFloor (QL::Instruments::YoYInflationCapFloor::TypeEnum type, Cephei::IVector<Cephei::QL::ICashFlow^>^ yoyLeg, Cephei::IVector<Double>^ strikes, Cephei::QL::IPricingEngine^ QL_Pricer) : CInstrument(CYoYInflationCapFloor::typeid)
{
    CoVector<Cephei::QL::ICashFlow^>^ _CyoyLeg;
    CoVector<Double>^ _Cstrikes;
    try
    {
#ifdef HANDLE
        _phYoYInflationCapFloor = NULL;
#endif
        QuantLib::YoYInflationCapFloor::Type _type = (QuantLib::YoYInflationCapFloor::Type)type ;
        _CyoyLeg = safe_cast<CoVector<Cephei::QL::ICashFlow^>^> (yoyLeg);
        _CyoyLeg ->Lock ();
        INativeVector<Cephei::QL::ICashFlow^>^ _NCIyoyLeg = _CyoyLeg->getFeature (NativeFeature::shared_ptr);
        CCashFlowVector^ _NCyoyLeg = safe_cast<CCashFlowVector^>(_NCIyoyLeg);
        std::vector<boost::shared_ptr<QuantLib::CashFlow> >& _yoyLeg = static_cast<std::vector<boost::shared_ptr<QuantLib::CashFlow> >&> (_NCyoyLeg->GetShared ());
        CoVector<Double>^ _Cstrikes = safe_cast<CoVector<Double>^> (strikes);
        _Cstrikes->Lock();
        INativeVector<Double>^ _NCIstrikes = _Cstrikes->getFeature (NativeFeature::Value);
        CDoubleVector^ _NCstrikes = safe_cast<CDoubleVector^>(_NCIstrikes);
        std::vector<QuantLib::Rate>& _strikes = static_cast<std::vector<QuantLib::Rate>&> (_NCstrikes->GetReference ());
        _ppYoYInflationCapFloor = new boost::shared_ptr<QuantLib::YoYInflationCapFloor> (new QuantLib::YoYInflationCapFloor ( _type,  _yoyLeg,  _strikes ));
        CPricingEngine^ _CQL_Pricer = safe_cast<CPricingEngine^> (QL_Pricer);
        boost::shared_ptr<QuantLib::PricingEngine>& _QL_Pricer = static_cast<boost::shared_ptr<QuantLib::PricingEngine>&> (_CQL_Pricer->GetShared ());
        (*_ppYoYInflationCapFloor)->setPricingEngine (_QL_Pricer);
        SetInstrument (boost::dynamic_pointer_cast<QuantLib::Instrument> (*_ppYoYInflationCapFloor));
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
        if (_CyoyLeg != nullptr) _CyoyLeg->Unlock();
        if (_Cstrikes != nullptr) _Cstrikes->Unlock();
    }
}
Cephei::QL::Instruments::CYoYInflationCapFloor::CYoYInflationCapFloor (QL::Instruments::YoYInflationCapFloor::TypeEnum type, Cephei::IVector<Cephei::QL::ICashFlow^>^ yoyLeg, Cephei::IVector<Double>^ capRates, Cephei::IVector<Double>^ floorRates, Cephei::QL::IPricingEngine^ QL_Pricer) : CInstrument(CYoYInflationCapFloor::typeid)
{
    CoVector<Cephei::QL::ICashFlow^>^ _CyoyLeg;
    CoVector<Double>^ _CcapRates;
    CoVector<Double>^ _CfloorRates;
    try
    {
#ifdef HANDLE
        _phYoYInflationCapFloor = NULL;
#endif
        QuantLib::YoYInflationCapFloor::Type _type = (QuantLib::YoYInflationCapFloor::Type)type ;
        _CyoyLeg = safe_cast<CoVector<Cephei::QL::ICashFlow^>^> (yoyLeg);
        _CyoyLeg ->Lock ();
        INativeVector<Cephei::QL::ICashFlow^>^ _NCIyoyLeg = _CyoyLeg->getFeature (NativeFeature::shared_ptr);
        CCashFlowVector^ _NCyoyLeg = safe_cast<CCashFlowVector^>(_NCIyoyLeg);
        std::vector<boost::shared_ptr<QuantLib::CashFlow> >& _yoyLeg = static_cast<std::vector<boost::shared_ptr<QuantLib::CashFlow> >&> (_NCyoyLeg->GetShared ());
        CoVector<Double>^ _CcapRates = safe_cast<CoVector<Double>^> (capRates);
        _CcapRates->Lock();
        INativeVector<Double>^ _NCIcapRates = _CcapRates->getFeature (NativeFeature::Value);
        CDoubleVector^ _NCcapRates = safe_cast<CDoubleVector^>(_NCIcapRates);
        std::vector<QuantLib::Rate>& _capRates = static_cast<std::vector<QuantLib::Rate>&> (_NCcapRates->GetReference ());
        CoVector<Double>^ _CfloorRates = safe_cast<CoVector<Double>^> (floorRates);
        _CfloorRates->Lock();
        INativeVector<Double>^ _NCIfloorRates = _CfloorRates->getFeature (NativeFeature::Value);
        CDoubleVector^ _NCfloorRates = safe_cast<CDoubleVector^>(_NCIfloorRates);
        std::vector<QuantLib::Rate>& _floorRates = static_cast<std::vector<QuantLib::Rate>&> (_NCfloorRates->GetReference ());
        _ppYoYInflationCapFloor = new boost::shared_ptr<QuantLib::YoYInflationCapFloor> (new QuantLib::YoYInflationCapFloor ( _type,  _yoyLeg,  _capRates,  _floorRates ));
        CPricingEngine^ _CQL_Pricer = safe_cast<CPricingEngine^> (QL_Pricer);
        boost::shared_ptr<QuantLib::PricingEngine>& _QL_Pricer = static_cast<boost::shared_ptr<QuantLib::PricingEngine>&> (_CQL_Pricer->GetShared ());
        (*_ppYoYInflationCapFloor)->setPricingEngine (_QL_Pricer);
        SetInstrument (boost::dynamic_pointer_cast<QuantLib::Instrument> (*_ppYoYInflationCapFloor));
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
        if (_CyoyLeg != nullptr) _CyoyLeg->Unlock();
        if (_CcapRates != nullptr) _CcapRates->Unlock();
        if (_CfloorRates != nullptr) _CfloorRates->Unlock();
    }
}
Cephei::QL::Instruments::CYoYInflationCapFloor::CYoYInflationCapFloor (boost::shared_ptr<QuantLib::YoYInflationCapFloor>& childNative, Object^ owner) : CInstrument(CYoYInflationCapFloor::typeid)
{
#ifdef HANDLE
	_phYoYInflationCapFloor = NULL;
#endif
	_ppYoYInflationCapFloor = &childNative;
    _ppInstrument = new boost::shared_ptr<QuantLib::Instrument> (boost::dynamic_pointer_cast<QuantLib::Instrument> (*_ppYoYInflationCapFloor));
}
Cephei::QL::Instruments::CYoYInflationCapFloor::CYoYInflationCapFloor (QuantLib::YoYInflationCapFloor& childNative, Object^ owner) : CInstrument(CYoYInflationCapFloor::typeid)
{
#ifdef HANDLE
	_phYoYInflationCapFloor = NULL;
#endif
	_ppYoYInflationCapFloor = new boost::shared_ptr<QuantLib::YoYInflationCapFloor> (&childNative);
    _ppInstrument = new boost::shared_ptr<QuantLib::Instrument> (boost::dynamic_pointer_cast<QuantLib::Instrument> (*_ppYoYInflationCapFloor));
    _YoYInflationCapFloorOwner = owner;
    _InstrumentOwner = owner;
}

Cephei::QL::Instruments::CYoYInflationCapFloor::CYoYInflationCapFloor (CYoYInflationCapFloor^ copy) : CInstrument(CYoYInflationCapFloor::typeid)
{
#ifdef HANDLE
	_phYoYInflationCapFloor = NULL;
#endif
	if (copy->HasNative() != NULL)
    {
		_ppYoYInflationCapFloor = new boost::shared_ptr<QuantLib::YoYInflationCapFloor> (copy->GetShared());
        _ppInstrument = new boost::shared_ptr<QuantLib::Instrument> (boost::dynamic_pointer_cast<QuantLib::Instrument> (*_ppYoYInflationCapFloor));
    }
}
Cephei::QL::Instruments::CYoYInflationCapFloor::CYoYInflationCapFloor (System::Type^ t) : CInstrument(CYoYInflationCapFloor::typeid)
{
#ifdef HANDLE
	_phYoYInflationCapFloor = NULL;
#endif
	if (!t->IsSubclassOf(CYoYInflationCapFloor::typeid))
		throw gcnew Exception ("Invalid base-case init");
}
#ifdef HANDLE
Cephei::QL::Instruments::CYoYInflationCapFloor::CYoYInflationCapFloor (QuantLib::Handle<QuantLib::YoYInflationCapFloor>& childNative, Object^ owner)  : CInstrument(CYoYInflationCapFloor::typeid)
{
	_phYoYInflationCapFloor = &childNative;
	_ppYoYInflationCapFloor = &static_cast<boost::shared_ptr<QuantLib::YoYInflationCapFloor>>(childNative.currentLink());
    _ppInstrument = new boost::shared_ptr<QuantLib::Instrument> (boost::dynamic_pointer_cast<QuantLib::Instrument> (*_ppYoYInflationCapFloor));
    _YoYInflationCapFloorOwner = owner;
}
Cephei::QL::Instruments::CYoYInflationCapFloor::CYoYInflationCapFloor (QuantLib::Handle<QuantLib::YoYInflationCapFloor> childNative)  : CInstrument(CYoYInflationCapFloor::typeid)
{
	_phYoYInflationCapFloor = &childNative;
	_ppYoYInflationCapFloor = &static_cast<boost::shared_ptr<QuantLib::YoYInflationCapFloor>>(childNative.currentLink());
    _ppInstrument = new boost::shared_ptr<QuantLib::Instrument> (boost::dynamic_pointer_cast<QuantLib::Instrument> (*_ppYoYInflationCapFloor));
}
#endif
#ifdef STRUCT
Cephei::QL::Instruments::CYoYInflationCapFloor::CYoYInflationCapFloor (QuantLib::YoYInflationCapFloor childNative)  : CInstrument(CYoYInflationCapFloor::typeid)
{
#ifdef HANDLE
	_phYoYInflationCapFloor = NULL;
#endif
	_ppYoYInflationCapFloor = new boost::shared_ptr<QuantLib::YoYInflationCapFloor> (new QuantLib::YoYInflationCapFloor (childNative));
    _ppInstrument = new boost::shared_ptr<QuantLib::Instrument> (boost::dynamic_pointer_cast<QuantLib::Instrument> (*_ppYoYInflationCapFloor));
}
#endif

Cephei::QL::Instruments::CYoYInflationCapFloor::~CYoYInflationCapFloor ()
{
    if (_ppYoYInflationCapFloor != NULL)
    {
	    delete _ppYoYInflationCapFloor;
        _ppYoYInflationCapFloor = NULL;
    }
}
Cephei::QL::Instruments::CYoYInflationCapFloor::!CYoYInflationCapFloor ()
{
    if (_ppYoYInflationCapFloor != NULL)
    {
	    delete _ppYoYInflationCapFloor;
    }
}
QuantLib::YoYInflationCapFloor& Cephei::QL::Instruments::CYoYInflationCapFloor::GetReference ()
{
    if (_ppYoYInflationCapFloor == NULL) throw gcnew NativeNullException ();
	return **_ppYoYInflationCapFloor;
}
boost::shared_ptr<QuantLib::YoYInflationCapFloor>& Cephei::QL::Instruments::CYoYInflationCapFloor::GetShared ()
{
    if (_ppYoYInflationCapFloor == NULL) throw gcnew NativeNullException ();
	return *_ppYoYInflationCapFloor;
}
QuantLib::YoYInflationCapFloor* Cephei::QL::Instruments::CYoYInflationCapFloor::GetPointer ()
{
    if (_ppYoYInflationCapFloor == NULL) throw gcnew NativeNullException ();
	return &**_ppYoYInflationCapFloor;
}
#ifdef HANDLE
QuantLib::Handle<QuantLib::YoYInflationCapFloor>& Cephei::QL::Instruments::CYoYInflationCapFloor::GetHandle ()
{
	if (_phYoYInflationCapFloor == NULL)
	{
		_phYoYInflationCapFloor = new Handle<QuantLib::YoYInflationCapFloor> (*_ppYoYInflationCapFloor);
	}
	return *_phYoYInflationCapFloor;
}
#endif
bool Cephei::QL::Instruments::CYoYInflationCapFloor::HasNative () 
{
	return (_ppYoYInflationCapFloor != NULL);
}

Double Cephei::QL::Instruments::CYoYInflationCapFloor::AtmRate (Cephei::QL::Termstructures::IYieldTermStructure^ discountCurve)
{
    CYieldTermStructure^ _CdiscountCurve;
    try
    {
        _CdiscountCurve = safe_cast<CYieldTermStructure^> (discountCurve);
        _CdiscountCurve->Lock();
        QuantLib::YieldTermStructure& _discountCurve = static_cast<QuantLib::YieldTermStructure&> (_CdiscountCurve->GetReference ()); 
    	QuantLib::Rate _rv = (QuantLib::Rate)(*_ppYoYInflationCapFloor)->atmRate ( _discountCurve );   
        Double _nrv = (Double)ValueHelper::Convert (_rv);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
        if (_CdiscountCurve != nullptr) _CdiscountCurve->Unlock();
    }
}
Cephei::IVector<Double>^ Cephei::QL::Instruments::CYoYInflationCapFloor::CapRates::get ()
{
    try
    {
    	std::vector<QuantLib::Rate>& _rv = (std::vector<QuantLib::Rate>&)(*_ppYoYInflationCapFloor)->capRates ( );   
        Cephei::IVector<Double>^ _nrv = gcnew CoVector<Double> (gcnew CDoubleVector (_rv));
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::IVector<Double>^ Cephei::QL::Instruments::CYoYInflationCapFloor::FloorRates::get ()
{
    try
    {
    	std::vector<QuantLib::Rate>& _rv = (std::vector<QuantLib::Rate>&)(*_ppYoYInflationCapFloor)->floorRates ( );   
        Cephei::IVector<Double>^ _nrv = gcnew CoVector<Double> (gcnew CDoubleVector (_rv));
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Instruments::CYoYInflationCapFloor::ImpliedVolatility (Double price, Cephei::QL::Termstructures::IYoYInflationTermStructure^ yoyCurve, Double guess, Microsoft::FSharp::Core::FSharpOption<Double>^ accuracy, Microsoft::FSharp::Core::FSharpOption<UInt32>^ maxEvaluations, Microsoft::FSharp::Core::FSharpOption<Double>^ minVol, Microsoft::FSharp::Core::FSharpOption<Double>^ maxVol)
{
    CYoYInflationTermStructure^ _CyoyCurve;
    try
    {
        QuantLib::Real _price = (QuantLib::Real)ValueHelper::Convert (price);
        _CyoyCurve = safe_cast<CYoYInflationTermStructure^> (yoyCurve);
        _CyoyCurve->Lock();
        Handle<QuantLib::YoYInflationTermStructure>& _yoyCurve = static_cast<Handle<QuantLib::YoYInflationTermStructure>&> (_CyoyCurve->GetHandle ()); 
        QuantLib::Volatility _guess = (QuantLib::Volatility)ValueHelper::Convert (guess);
        QuantLib::Real _accuracy = 
            (Microsoft::FSharp::Core::FSharpOption<Double>::IsSome::get (accuracy) ? (QuantLib::Real)ValueHelper::Convert (accuracy->Value) : 1.0e-4); //9a
        QuantLib::Natural _maxEvaluations = 
            (Microsoft::FSharp::Core::FSharpOption<UInt32>::IsSome::get (maxEvaluations) ? (QuantLib::Natural)ValueHelper::Convert (maxEvaluations->Value) : 100); //9a
        QuantLib::Volatility _minVol = 
            (Microsoft::FSharp::Core::FSharpOption<Double>::IsSome::get (minVol) ? (QuantLib::Volatility)ValueHelper::Convert (minVol->Value) : 1.0e-7); //9a
        QuantLib::Volatility _maxVol = 
            (Microsoft::FSharp::Core::FSharpOption<Double>::IsSome::get (maxVol) ? (QuantLib::Volatility)ValueHelper::Convert (maxVol->Value) : 4.0); //9a
    	QuantLib::Volatility _rv = (QuantLib::Volatility)(*_ppYoYInflationCapFloor)->impliedVolatility ( _price,  _yoyCurve,  _guess,  _accuracy,  _maxEvaluations,  _minVol,  _maxVol );   
        Double _nrv = (Double)ValueHelper::Convert (_rv);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
        if (_CyoyCurve != nullptr) _CyoyCurve->Unlock();
    }
}
Boolean Cephei::QL::Instruments::CYoYInflationCapFloor::IsExpired::get ()
{
    try
    {
    	bool _rv = (bool)(*_ppYoYInflationCapFloor)->isExpired ( );   
        Boolean _nrv = (Boolean)ValueHelper::Convert (_rv);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Cashflows::IYoYInflationCoupon^ Cephei::QL::Instruments::CYoYInflationCapFloor::LastYoYInflationCoupon::get ()
{
    try
    {
    	boost::shared_ptr<QuantLib::YoYInflationCoupon> _rv = (boost::shared_ptr<QuantLib::YoYInflationCoupon>)(*_ppYoYInflationCapFloor)->lastYoYInflationCoupon ( );   
        Cephei::QL::Cashflows::CYoYInflationCoupon^ _nrv = gcnew Cephei::QL::Cashflows::CYoYInflationCoupon (_rv, this);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
DateTime Cephei::QL::Instruments::CYoYInflationCapFloor::MaturityDate::get ()
{
    try
    {
    	QuantLib::Date _rv = (QuantLib::Date)(*_ppYoYInflationCapFloor)->maturityDate ( );   
        DateTime _nrv = (DateTime)ValueHelper::Convert (_rv);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Instruments::IYoYInflationCapFloor^ Cephei::QL::Instruments::CYoYInflationCapFloor::Optionlet (UInt64 n)
{
    try
    {
        QuantLib::Size _n = (QuantLib::Size)ValueHelper::Convert (n);
    	boost::shared_ptr<QuantLib::YoYInflationCapFloor> _rv = (boost::shared_ptr<QuantLib::YoYInflationCapFloor>)(*_ppYoYInflationCapFloor)->optionlet ( _n );   
        Cephei::QL::Instruments::CYoYInflationCapFloor^ _nrv = gcnew Cephei::QL::Instruments::CYoYInflationCapFloor (_rv, this);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
DateTime Cephei::QL::Instruments::CYoYInflationCapFloor::StartDate::get ()
{
    try
    {
    	QuantLib::Date _rv = (QuantLib::Date)(*_ppYoYInflationCapFloor)->startDate ( );   
        DateTime _nrv = (DateTime)ValueHelper::Convert (_rv);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
QL::Instruments::YoYInflationCapFloor::TypeEnum Cephei::QL::Instruments::CYoYInflationCapFloor::Type::get ()
{
    try
    {
    	QuantLib::YoYInflationCapFloor::Type _rv = (QuantLib::YoYInflationCapFloor::Type)(*_ppYoYInflationCapFloor)->type ( );   
        QL::Instruments::YoYInflationCapFloor::TypeEnum _nrv = (QL::Instruments::YoYInflationCapFloor::TypeEnum)_rv;
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::IVector<Cephei::QL::ICashFlow^>^ Cephei::QL::Instruments::CYoYInflationCapFloor::YoyLeg::get ()
{
    try
    {
    	std::vector<boost::shared_ptr<QuantLib::CashFlow> >& _rv = (std::vector<boost::shared_ptr<QuantLib::CashFlow> >&)(*_ppYoYInflationCapFloor)->yoyLeg ( );   
        CoVector<Cephei::QL::ICashFlow^>^ _nrv = gcnew CoVector<Cephei::QL::ICashFlow^>(gcnew CCashFlowVector (_rv, this));
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Factory class

Cephei::QL::Instruments::IYoYInflationCapFloor^ Cephei::QL::Instruments::CYoYInflationCapFloor_Factory::Create (QL::Instruments::YoYInflationCapFloor::TypeEnum type, Cephei::IVector<Cephei::QL::ICashFlow^>^ yoyLeg, Cephei::IVector<Double>^ strikes, Cephei::QL::IPricingEngine^ QL_Pricer)
{
    return gcnew CYoYInflationCapFloor ( type,  yoyLeg,  strikes,  QL_Pricer);
}
Cephei::QL::Instruments::IYoYInflationCapFloor^ Cephei::QL::Instruments::CYoYInflationCapFloor_Factory::Create (QL::Instruments::YoYInflationCapFloor::TypeEnum type, Cephei::IVector<Cephei::QL::ICashFlow^>^ yoyLeg, Cephei::IVector<Double>^ capRates, Cephei::IVector<Double>^ floorRates, Cephei::QL::IPricingEngine^ QL_Pricer)
{
    return gcnew CYoYInflationCapFloor ( type,  yoyLeg,  capRates,  floorRates,  QL_Pricer);
}
